﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;

namespace SES.CMS
{
    public partial class Content : System.Web.UI.Page
    {
        cmsCategoryDO objCat = new cmsCategoryDO();
        protected void Page_Load(object sender, EventArgs e)
        {
            MasterPage mt = this.Master as MasterPage;
            Control uc = mt.FindControl("ucHomeSlide1") as Control;
            uc.Visible = false;
            if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
            {
                int CategoryID = int.Parse(Request.QueryString["ID"].ToString());
                objCat.CategoryID = CategoryID;

                objCat = new cmsCategoryBL().Select(objCat);
                hplCate.Text = objCat.Title;
                hplCate.NavigateUrl = FriendlyUrl2(objCat.Title) + "/Content/" + objCat.CategoryID.ToString() + "/" + FriendlyUrl(objCat.Title);
                ltrDes.Text = objCat.DetailContent;
                //rptNews.DataSource = new cmsCategoryBL().SelectOne(objCat);
                //rptNews.DataBind();
                DataTable dtOther = new cmsArticleBL().SelectByCatNum(objCat.CategoryID, 100);
                if (!IsPostBack)
                {
                    Page.Title = objCat.Title + " - " + Ultility.PageTitle();
                    HtmlMeta metaDesc = new HtmlMeta();
                    metaDesc.Name = "description";
                    metaDesc.Content = new sysConfigBL().Select(new sysConfigDO { ConfigID = 1 }).ConfigValue;
                    Page.Header.Controls.Add(metaDesc); 

                    rptOtherNews.DataSource = dtOther;
                    rptOtherNews.DataBind();
                }
            }
        }
        protected string FriendlyUrl(string strTitle)
        {
            return Ultility.Change_AV(strTitle);
        }

        public string FriendlyUrl2(string s)
        {
            return Ultility.Change_AV2(s);
        }

        public string CategoryTitle(string CategoryID)
        {
            string CategoryTitle = "";
            CategoryTitle = FriendlyUrl2(new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = int.Parse(CategoryID) }).Title);
            return CategoryTitle;
        }
    }
}
